import QtQuick 2.15
import QtQuick.Controls 2.15


/**
  * 自定义菜单条
  */
MenuBar {
    id: cusMenuBar

    anchors.left: parent.left
    anchors.right: parent.right

    property color menuBgColor: "#fff"
    property color menuBgActiveColor: "#f2f6fa"
    property color menuFontColor: "#000"
    property color menuFontActiveColor: "#000"

    delegate: MenuBarItem {
        id: menuBarItem

        // 菜单条目设置
        contentItem: Text {
            text: menuBarItem.text
            font: menuBarItem.font
            opacity: enabled ? 1.0 : 0.3
            color: menuBarItem.highlighted ? cusMenuBar.menuFontActiveColor : cusMenuBar.menuFontColor
            horizontalAlignment: Text.AlignLeft
            verticalAlignment: Text.AlignVCenter
            elide: Text.ElideRight
        }

        background: Rectangle {
            implicitWidth: 40
            implicitHeight: 40
            opacity: enabled ? 1 : 0.3
            color: menuBarItem.highlighted ? cusMenuBar.menuBgActiveColor : "transparent"
        }
    }

    // 整个菜单栏背景设置
    background: Rectangle {
        implicitWidth: 40
        implicitHeight: 40
        color: cusMenuBar.menuBgColor

        // 菜单栏底部分割线
        Rectangle {
            color: cusMenuBar.menuBgActiveColor
            width: parent.width
            height: 1
            anchors.bottom: parent.bottom
        }
    }
}
